package 线程的状态;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-11-22
 * Time: 14:28
 */
public class Daemon {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            System.out.println("t1 : 开始运行...");
            while(true){
                if(Thread.currentThread().isInterrupted()){
                    break;
                }
            }
            System.out.println("t1 : 结束运行...");
        },"t1");
        t.setDaemon(true);//设置t线程为守护线程
        t.start();//启动线程
        Thread.sleep(1000);
        System.out.println("main : 结束!!!");
    }
}
